package service

import (
	"cms/model"
	"engine/dto"
	emodel "engine/model"
)

func HandleOtcOrder(pageList *dto.PaginationList[emodel.My_otc_order], uid uint64, types string) *dto.PaginationList[model.OtcResp] {
	var newData dto.PaginationList[model.OtcResp]
	newList := make([]*model.OtcResp, 0)
	if types == "0" || types == "1" || types == "2" || types == "3" {
		uid = 0
	}

	for _, item := range pageList.Items {
		ouid := item.Uid
		if types == "0" || types == "1" || types == "2" || types == "3" {
			ouid = 0
		}
		newList = append(newList, &model.OtcResp{
			Id:         item.Id,
			Amount:     item.Amount,
			Price:      item.Price,
			Num:        item.Num,
			MUid:       uid,
			CreateTime: item.CreateTime,
			JdTime:     item.JdTime,
			QxTime:     item.QxTime,
			WcTime:     item.WcTime,
			OUid:       ouid,
			Status:     item.Status,
			Score:      item.Score,
		})
	}
	newData.Items = newList
	newData.Total = pageList.Total
	newData.Page = pageList.Page
	newData.PageSize = pageList.PageSize
	return &newData
}
